package com.xijia.wuyouwallet.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.alibaba.fastjson.JSONObject;
import com.xijia.wuyouwallet.R;
import com.xijia.wuyouwallet.api.MyCallBack;
import com.xijia.wuyouwallet.base.BaseActivity;
import com.xijia.wuyouwallet.bean.AboutUsData;
import com.xijia.wuyouwallet.config.FusionField;
import com.xijia.wuyouwallet.utils.MyLogger;
import com.xijia.wuyouwallet.utils.UrlConfig;
import com.xijia.wuyouwallet.utils.XUtil;

/**
 * Created by Administrator on 2017/7/17 0017.
 */

public class AboutusActivity extends BaseActivity implements View.OnClickListener{


    private ImageView aboutus_back;
    private TextView aboutus_version,aboutus_contentTv;
    private RelativeLayout aboutus_serve;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aboutus);
        initView();
    }
    private void initView(){
        aboutus_back = (ImageView) findViewById(R.id.aboutus_back);
        aboutus_back.setOnClickListener(this);
        aboutus_version = (TextView) findViewById(R.id.aboutus_version);
        aboutus_contentTv = (TextView) findViewById(R.id.aboutus_contentTv);
        aboutus_serve = (RelativeLayout) findViewById(R.id.aboutus_serve);
        aboutus_serve.setOnClickListener(this);
        aboutus_version.setText(FusionField.currentVersion);
        requestData();
    }
    private void requestData(){
        showProgressDialog(true);
        XUtil.Post(UrlConfig.ABOUT_US_URL,null,new MyCallBack<String>(){

            @Override
            public void onSuccess(String result) {
                super.onSuccess(result);
                dismissProgressDialog();
                MyLogger.wLog().e("获取关于我们result="+result);
                AboutUsData data = JSONObject.parseObject(result,AboutUsData.class);
                if (data.getCode()==200){
                    aboutus_contentTv.setText(data.getData().getData());
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                dismissProgressDialog();
                MyLogger.wLog().e("获取关于我们onError="+ex.toString());
            }
        });
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.aboutus_serve:
                jumpToPage(ServeActivity.class);
                break;
            case R.id.aboutus_back:
                finish();
                break;
        }
    }
}
